package api

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log/dingding"
)

type User struct {
	Server string `form:"server" binding:"required"`
	Err    string `form:"err" binding:"required"`
}

func dd(c *gin.Context) {
	var u User
	//参数绑定和验证返回400
	err := c.ShouldBindQuery(&u)
	if err != nil {
		c.String(400, "参数错误")
		return
	}
	//钉钉发送消息
	dingding.DDSend(fmt.Sprintf("服务名称：%s，err报错：%s", u.Server, u.Err))
	c.JSON(200, gin.H{
		"status":     "请求成功",
		"servername": u.Server,
		"err":        u.Err,
	})

}
